package me.yannchou.weicoer.ui.main.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import me.yannchou.weicoer.R;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zhouyanbin
 * @time 2014/11/25.21:32
 */
public class NavigationFragment extends Fragment {


    private View rootView;

    private List<String> items = new ArrayList<String>();
    private ArrayAdapter<String> adapter;
    private ListView listView;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        items.add("Item1");
        items.add("Item2");
        items.add("Item3");
        items.add("Item4");
        items.add("Item5");
        items.add("Item6");
        adapter = new ArrayAdapter<String>(getActivity(),android.R.layout.simple_list_item_1,items);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        if (rootView==null){
            rootView = inflater.inflate(R.layout.navigation_drawer_layout,container,false);
            listView = (ListView) rootView.findViewById(R.id.drawer_listView);
            listView.setAdapter(adapter);
        }else {
            ViewGroup parent = (ViewGroup) rootView.getParent();
            if (parent!=null){
                parent.removeView(rootView);
            }
        }
        return rootView;
    }

}
